/*
 * Created on 2005-1-24
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.karelun.gef.commands;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.karelun.gef.model.Node;

public class ChangeNodeConstraintCommand extends AbstractCommand {
	
    private Node node;

    private Point oldPos;

    private Point newPos;

    private Dimension newSize;

    public void setLocation(Point p) {
        oldPos = this.node.getLocation();
        this.newPos = p;
    }

    public void setDimension(Dimension d) {
        this.newSize = d;
    }

    public void setNode(Node node) {
        this.node = node;
    }

    public void execute() {
        node.setLocation(newPos);
        node.setSize(newSize);
    }

    public void redo() {
        execute();
    }

    public void undo() {
        node.setLocation(oldPos);
        node.setSize(newSize);
    }
}